#include <iostream>
#include <string.h>
using namespace std;

class password
{
public:
    void setpassword(char *p)
    {
        strcpy(pwd,p);
        cout << "密码设置成功" << endl;
        cout << "当前密码为：" << pwd << endl;
    }
    int checkpassword(char *p)
    {
        if(strcmp(pwd,p)==0)
        {
            cout << "密码正确" << endl;
            return 0;
        }else
        {
            cout << "密码错误" << endl;
            return 1;
        }
    }
    void changePassword(char *oldpass, char *newpass)
    {
        if(checkpassword(oldpass)==0)
        {
            strcpy(pwd,newpass);
            cout << "密码修改成功" << endl;
        }else
        {
            cout << "密码修改失败" << endl;
        }
    }
private:
    char pwd[100];
};

int main()
{
    password p1;
    char pwd[100] = "123456";
    char oldpass[100] = "123456";
    char newpass[100] = "654321";
    p1.setpassword(pwd);
    p1.checkpassword(oldpass);
    p1.changePassword(oldpass,newpass);
    p1.checkpassword(newpass);
    return 0;
}